package com.winning.yanghao.designpattern.singleton.seriable;

import java.io.*;

public class SeriableTest {

    public static void main(String[] args) {

        Seriable s1 = null;
        Seriable s2 = Seriable.getInstance();

        try {
            FileOutputStream out = new FileOutputStream("Seriable.io");
            ObjectOutputStream oos = new ObjectOutputStream(out);

            oos.writeObject(s2);
            oos.flush();
            oos.close();

            FileInputStream in = new FileInputStream("Seriable.io");
            ObjectInputStream ois = new ObjectInputStream(in);

            s1 = (Seriable) ois.readObject();
            System.out.println(s1);
            System.out.println(s2);

        }catch (Exception e){
            e.printStackTrace();
        }
    }


}
